#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/11/6 19:54
# @Author  : 作者名:张铁君
# @Site    : 
# @File    : LoginPage.py
# @Project : h5_auto_test
# @Software: PyCharm
import time

from selenium.webdriver.common.by import By

from base.HomeBase import HomeBase
from base.ObjectMap import ObjectMap
from logs.log import log


class HomePage(HomeBase, ObjectMap):
    def click_menu(self, driver, menu_name):
        log.info("输入：" + menu_name)
        menu = self.menu_path(menu_name)
        return self.element_click(driver, By.XPATH, menu)

    def to_normal_bx(self, driver):
        self.element_click(driver, By.XPATH, "//span[text()='综合报销单']")
        time.sleep(0.1)
        self.element_click(driver, By.XPATH, "//label[contains(text(),'银行汇款')]")
        self.element_click(driver, By.XPATH, "//label[contains(text(),'现金')]")
        # 点击新增银行汇款
        self.element_click(driver, By.XPATH, "//*[@id=\"formDiv\"]/div[2]/div/div[2]/div[2]/div/div[2]/button")
        self.element_click(driver, By.XPATH, "//*[@id=\"formDiv\"]/div[2]/div/div[2]/div[3]/div/div[2]/button")
        # 点击项目
        self.save_screenshot1(driver)
        self.element_click(driver, By.XPATH,
                           "//*[@id=\"formDiv\"]/div[2]/div/div[2]/div[2]/table/tbody/tr[1]/td[1]/span")
        time.sleep(0.5)
        # 输入搜索项目
        self.element_fill_value(driver, By.XPATH, "/html/body/div[15]/div[2]/div/div/div[2]/div[1]/div/input", "机关")
        self.element_click(driver, By.XPATH, "/html/body/div[15]/div[2]/div/div/div[2]/div[1]/div/div")
        time.sleep(0.5)
        self.save_screenshot1(driver)
        self.element_click(driver, By.XPATH, "/html/body/div[15]/div[2]/div/div/div[2]/div[2]/table/tbody/tr/td[6]/a")
        time.sleep(0.2)
        self.save_screenshot1(driver)
        # 选择预算类型
        self.element_click(driver, By.XPATH,
                           "//*[@id=\"formDiv\"]/div[2]/div/div[2]/div[2]/table/tbody/tr[1]/td[2]/div/div/div/div/span")
        self.save_screenshot1(driver)
        self.element_click(driver, By.XPATH, "/html/body/div[17]/ul[2]/li[5]")
        self.save_screenshot1(driver)
        pass

    def to(self, driver):
        self.click_menu(driver, "报销管理")
        time.sleep(0.2)
        self.save_screenshot1(driver)
        self.click_menu(driver, "我要报销")
        time.sleep(0.1)
        self.save_screenshot1(driver)
        self.to_normal_bx(driver)
